/*
 * Dummy web service simulating sending mails
 */

package smtp;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/**
 *
 * @author ernestoexposito
 */
@WebService()
public class SMTPWebService {

    /**
     * Web service operation
     */
    @WebMethod(operationName = "sendMail")
    public String sendMail(@WebParam(name = "to")
    String to, @WebParam(name = "subject")
    String subject, @WebParam(name = "text")
    String text) {
        //TODO write your implementation code here:

        String result= "to:"+to+
                "|subject:"+subject+
                "|text:"+text;
       try {
            BufferedWriter out = new BufferedWriter(new FileWriter(new File("../logs/logsmtp.txt"),true));
            out.write(result);
            out.newLine();
            out.flush();

        } catch (IOException ex) {
            Logger.getLogger(SMTPWebService.class.getName()).log(Level.SEVERE, null, ex);
        }

        System.out.println(result);

        return result;
    }

}
